home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak Vol A-4
/
(Vol A-4) Vol. A4.iso
/
Games
/
tom_jerry_bowling.swf
/
scripts
/
frame_12
/
DoAction.as
Wrap
Text File
|
2008-03-04
|
10KB
|
399 lines
function resetGame()
{
i = 1;
while(i <= 10)
{
gameMC["frame-" + i] = "-";
i++;
}
frameNum = 1;
rollNum = 1;
pinsUp = [1,2,3,4,5,6,7,8,9,10];
pinsDown = new Array();
score = 0;
currentRoll = 0;
power = "";
pan = 0;
pinSplit = false;
showFrameNum();
}
function pinCheck()
{
trace(pinsUp + " are the pins still standing.");
trace(pinsDown + " are the pins knocked down.");
trace("--------------------------------------------");
}
function mouseDownFunction()
{
if(gameMC.gameState == "pickPan")
{
gameMC.laneLights.gotoAndPlay("L" + gameMC.pan);
gameMC.gameState = "pickPower";
gameMC.powerMeter.gotoAndPlay("loopHere");
}
}
function mouseUpFunction()
{
if(gameMC.gameState == "pickPower")
{
gameMC.randomOneToThree = Math.floor(Math.random() * 3) + 1;
gameMC.powerMeter.stop();
gameMC.gameState = "bowl";
gameMC.jackie.gotoAndPlay("throw-" + gameMC.power);
}
}
function showFrameNum()
{
gameMC.alerts.num.gotoAndStop(frameNum);
gameMC.alerts.gotoAndPlay("gameFrame");
}
function tapPin(pinNum)
{
var _loc1_ = pinNum;
numOfPinsUp = pinsUp.length;
i = 0;
while(i < numOfPinsUp)
{
if(_loc1_ == pinsUp[i])
{
gameMC["pin-" + _loc1_].gotoAndPlay("wobble");
break;
}
i++;
}
}
function testPin(pinNum)
{
var _loc1_ = pinNum;
numOfPinsUp = pinsUp.length;
i = 0;
while(i < numOfPinsUp)
{
if(_loc1_ == pinsUp[i])
{
gameMC.pinsUp.splice(i,1);
gameMC.pinsDown.push(_loc1_);
gameMC["pin-" + _loc1_].gotoAndPlay("hit");
gameMC.currentRoll = gameMC.currentRoll + 1;
break;
}
i++;
}
}
function pickUpTheSplit(side)
{
gameMC.pinsUp = [];
gameMC.pinsDown.push(4,7,6,10);
gameMC.currentRoll = 4;
if(side == "left")
{
gameMC["pin-4"].gotoAndPlay("hitLeft");
gameMC["pin-6"].gotoAndPlay("hitLeft");
gameMC["pin-7"].gotoAndPlay("hit");
gameMC["pin-10"].gotoAndPlay("hit");
}
else if(side == "right")
{
gameMC["pin-4"].gotoAndPlay("hitRight");
gameMC["pin-6"].gotoAndPlay("hitRight");
gameMC["pin-7"].gotoAndPlay("hit");
gameMC["pin-10"].gotoAndPlay("hit");
}
}
function updatePinLights()
{
numOfPinsDown = pinsDown.length;
i = 0;
while(i <= numOfPinsDown)
{
thisPin = pinsDown[i];
gameMC.pinLights["pinLight-" + thisPin].gotoAndPlay("unlit");
i++;
}
}
function playHitSound()
{
i = 1;
while(i <= 3)
{
gameMC["sound_" + i].stop();
i++;
}
if(gameMC.currentRoll == 0)
{
sound_7.start(0,0);
}
else if(gameMC.currentRoll < 4)
{
sound_4.start(0,0);
}
else if(gameMC.currentRoll <= 7)
{
sound_5.start(0,0);
}
else if(gameMC.currentRoll > 7)
{
sound_6.start(0,0);
}
}
function resetBall()
{
ball.gotoAndPlay(1);
laneLights.gotoAndPlay("L" + pan + "_fade");
markIt();
}
function markIt()
{
if(rollNum == 1)
{
if(gameMC["frame_" + (frameNum - 1) + "-2"]._currentframe == 12)
{
score += 10 + currentRoll;
gameMC["frame-" + (frameNum - 1)] = score;
}
if(gameMC["frame_" + (frameNum - 1) + "-2"]._currentframe == 13)
{
if(gameMC["frame_" + (frameNum - 2) + "-2"]._currentframe == 13)
{
score += 20 + currentRoll;
gameMC["frame-" + (frameNum - 2)] = score;
if(currentRoll == 10)
{
gameMC.moreAlerts.gotoAndPlay("turkey");
}
}
}
if(currentRoll == 10)
{
gameMC.jackie.gotoAndPlay("strike");
if(frameNum == 10)
{
gameMC["frame_" + frameNum + "-1"].gotoAndStop("strike");
}
else
{
gameMC["frame_" + frameNum + "-2"].gotoAndStop("strike");
}
gameMC.alerts.gotoAndPlay("strike");
}
else
{
if(currentRoll == 0)
{
gameMC.jackie.gotoAndPlay("lose");
gameMC.alerts.gotoAndPlay("gutterball");
}
else
{
gameMC.jackie.gotoAndPlay("stall");
gameMC.alerts.count.gotoAndStop(gameMC.pinsDown.length);
gameMC.alerts.gotoAndPlay("count");
}
gameMC["frame_" + frameNum + "-1"].gotoAndStop(currentRoll + 2);
rollNum = 2;
}
}
else if(rollNum == 2)
{
if(gameMC["frame_" + (frameNum - 1) + "-2"]._currentframe == 13)
{
if(gameMC["frame_" + frameNum + "-1"]._currentframe == 13)
{
score += 20 + pinsDown.length;
}
else
{
score += 10 + pinsDown.length;
}
gameMC["frame-" + (frameNum - 1)] = score;
}
if(frameNum == 10)
{
if(gameMC["frame_10-1"]._currentframe == 13)
{
score += 10;
if(pinsUp.length == 0)
{
score += 10;
gameMC["frame_10-2"].gotoAndStop("strike");
gameMC.jackie.gotoAndPlay("strike");
gameMC.alerts.gotoAndPlay("strike");
}
else
{
gameMC["frame_10-2"].gotoAndStop(currentRoll + 2);
rollNum = 3;
gameMC.alerts.count.gotoAndStop(gameMC.pinsDown.length);
gameMC.alerts.gotoAndPlay("count");
}
}
else if(pinsUp.length == 0)
{
gameMC["frame_10-2"].gotoAndStop("spare");
gameMC.jackie.gotoAndPlay("spare");
gameMC.alerts.gotoAndPlay("spare");
score += 10;
}
else
{
gameMC["frame_10-2"].gotoAndStop(currentRoll + 2);
score += pinsDown.length;
markFinalScore();
}
}
else if(pinsUp.length == 0)
{
gameMC.jackie.gotoAndPlay("fist");
gameMC["frame_" + frameNum + "-2"].gotoAndStop("spare");
}
else
{
gameMC["frame_" + frameNum + "-2"].gotoAndStop(currentRoll + 2);
score += gameMC.pinsDown.length;
gameMC["frame-" + frameNum] = score;
gameMC.jackie.gotoAndPlay("stall");
gameMC.alerts.gotoAndPlay("wait");
}
}
else if(rollNum == 3)
{
if(pinsUp.length == 0)
{
score += 10;
if(gameMC["frame_10-2"]._currentframe > 11)
{
gameMC["frame_10-3"].gotoAndStop("strike");
}
else
{
gameMC["frame_10-3"].gotoAndStop("spare");
}
}
else
{
gameMC["frame_10-3"].gotoAndStop(currentRoll + 2);
score += gameMC.pinsDown.length;
}
markFinalScore();
}
updatePinLights();
}
function markFinalScore()
{
gameMC.jackie.gotoAndPlay("stall");
gameMC.logo.gotoAndStop("smiling");
gameMC["frame-10"] = score;
gameMC.finalScore = score;
gameMC.alerts.gotoAndPlay("finalScore");
}
function newFrame()
{
resetPins();
if(gameMC.frameNum < 10)
{
rollNum = 1;
frameNum++;
gameMC.frameBoxes.gotoAndStop(frameNum);
}
else if(gameMC.rollNum == 1)
{
gameMC.rollNum = 2;
}
else if(gameMC.rollNum == 2)
{
gameMC.rollNum = 3;
}
pinSplit = false;
i = 1;
while(i <= 10)
{
gameMC.pinLights["pinLight-" + i].gotoAndPlay("lit");
i++;
}
}
function pickPan()
{
currentRoll = 0;
gameState = "pickPan";
powerMeter.play();
jackie.gotoAndPlay("idle");
laneLights.gotoAndPlay("blink");
}
function resetPins()
{
pinsUp = [1,2,3,4,5,6,7,8,9,10];
pinsDown = [];
gameMC.ctrlclip.gotoAndPlay("setPins");
}
function getScore()
{
return score;
}
function openHelpWin()
{
trace("displaying help");
gameMC.helpWin_mc.open();
}
function closeHelpWin()
{
if(helpWindow._currentframe > 1)
{
helpWindow.play();
}
}
function pause()
{
helpButton.helpButton.enabled = false;
set("variables:pause",true);
}
function unPause()
{
helpButton.helpButton.enabled = true;
set("variables:pause",false);
}
function getAdInfo()
{
var _loc1_ = {id:1,path:"ad1.jpg",link:"http://www.kidswb.com",text:"howdy"};
return _loc1_;
}
function adClick()
{
getURL(gameMC.adInfo.link,"");
}
function displayAd(ad)
{
gameMC.adInfo = ad;
gameMC.ad_100x100.loadMovie(ad.path);
}
function restart()
{
containerMC.resetContainer();
containerMC.init();
score = 0;
which_level = 1;
}
resetGame();
gameMC.createEmptyMovieClip("soundLib",1);
i = 1;
while(i <= 9)
{
soundLib.createEmptyMovieClip("holder_" + i,i);
gameMC["sound_" + i] = new Sound(soundLib["holder_" + i]);
i++;
}
sound_1.attachSound("lightRoll");
sound_2.attachSound("mediumRoll");
sound_3.attachSound("hardRoll");
sound_4.attachSound("lightHit");
sound_5.attachSound("mediumHit");
sound_6.attachSound("hardHit");
sound_7.attachSound("gutter");
sound_8.attachSound("loop");
sound_9.attachSound("wood");
if(initGame == null)
{
initGame = true;
containerMC.init();
displayAd(containerMC.getAdInfo());
}